]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
iconGrid: Fix slowness on pulse animation for few items
authorCarlos Soriano <carlos.soriano89@gmail.com>
Fri, 19 Sep 2014 17:25:35 +0000 (19:25 +0200)
committerCarlos Soriano <carlos.soriano89@gmail.com>
Thu, 9 Oct 2014 10:47:16 +0000 (12:47 +0200)
Currently we use the same amount of total delay divided by all items,
but that makes the items animate slow if the amount of items is small.
To avoid that, use a smaller total amount delay for an amount of items
smaller than four.

https://bugzilla.gnome.org/show_bug.cgi?id=737017

js/ui/iconGrid.js

index a35489b61d6f387bce77d7ffa909dbb8324cdf45..875450191b6936cd5bb41a4a5b0e28281bce9eea 100644 (file)
@@ -20,6 +20,7 @@ const EXTRA_SPACE_ANIMATION_TIME = 0.25;
 const ANIMATION_TIME_IN = 0.350;
 const ANIMATION_TIME_OUT = 1/2 * ANIMATION_TIME_IN;
 const ANIMATION_MAX_DELAY_FOR_ITEM = 2/3 * ANIMATION_TIME_IN;
+const ANIMATION_BASE_DELAY_FOR_ITEM = 1/4 * ANIMATION_MAX_DELAY_FOR_ITEM;
 const ANIMATION_MAX_DELAY_OUT_FOR_ITEM = 2/3 * ANIMATION_TIME_OUT;
 const ANIMATION_FADE_IN_TIME_FOR_ITEM = 1/4 * ANIMATION_TIME_IN;
 
@@ -429,13 +430,20 @@ const IconGrid = new Lang.Class({
             return;
         }
 
+        // For few items the animation can be slow, so use a smaller
+        // delay when there are less than 4 items
+        // (ANIMATION_BASE_DELAY_FOR_ITEM = 1/4 *
+        // ANIMATION_MAX_DELAY_FOR_ITEM)
+        let maxDelay = Math.min(ANIMATION_BASE_DELAY_FOR_ITEM * actors.length,
+                                ANIMATION_MAX_DELAY_FOR_ITEM);
+
         for (let index = 0; index < actors.length; index++) {
             let actor = actors[index];
             actor.reactive = false;
             actor.set_scale(0, 0);
             actor.set_pivot_point(0.5, 0.5);
 
-            let delay = index / actors.length * ANIMATION_MAX_DELAY_FOR_ITEM;
+            let delay = index / actors.length * maxDelay;
             let bounceUpTime = ANIMATION_TIME_IN / 4;
             let isLastItem = index == actors.length - 1;
             Tweener.addTween(actor,